<template>
	<!-- //微信小程序 ：style="[]" 要用数组的形式 -->
	<view class="custom-page-defalut">
		<tree-selector :Skey="Skey" :payload="data"></tree-selector>
	</view>
</template>

<script>
	import * as OrganizationApi from '@/network/apis/organization.js';
	import * as tools from '@/library/utils/tool.js';
	import * as DictApis from '@/network/apis/dict.js'
	// 用法: type:判断不同类型 key:判断同一类型不同字段
	export default {
		components: {},
		data() {
			return {
				form: {
					dictHeaderCode: "风险区域",
					withDisable: false
				},
				data: [],
				Skey:'title'
			}
		},
		onLoad(payload) {
			console.log(payload)
			//选择工区
			if (payload && payload.type == 'Organization') {
				uni.showLoading({
					
				})
				OrganizationApi.getall({
					marks: [2],
					withDisable: false
				}).then(res=>{
					if(res&&res.success){
						this.data = tools.listToTree(res.data);
					}else{
					   uni.showToast({
					   	icon:'none',
						title:res.mesage
					   })
					}
					uni.hideLoading();
				})
			}
			uni.$on('tree-selector-confirm', res => {
				if(payload.key){
					res.key = payload.key;
				}
				console.log('tree-selector-confirm:', res)
				//选择工区
				if (payload && payload.type == 'Organization') {
					uni.$emit('GetOrganization', res);

				}
				
			})
		},
		onUnload() {
			uni.$off('tree-selector-confirm')
		}
	}
</script>

<style scoped>

</style>